Gets details for the current user.

{ getMe }

Returns the user info for the currently authenticated user

Method

/API2/access/getMe

  • API Section: /API2/access
  • API Version: 2.0
  • From Release: 2020.0
  • Can be used by Non-admin accounts
  • Method operates via POST actions only.
  • Output Response

    Successful Result Code

    200

    Response Type

    Description of Response Type

    The user object contains all relevant meta-data for the user.

    Notes

    Use this method to extact details for the account running the API calls

    Examples
    Authenticate User (JavaScript):

    This example demonstrates how to authenticate a user from JavaScript.

    // URL of the Pyramid installation and the path to the API 2.0 REST methods
    var pyramidURL = "http://mysite.com/api2/";
    
    // step 1: authenticate user account and get token
    // NOTE: callApi method is a generic REST method shown below.
    let token = callApi("auth/authenticateUser",{
    	"data":{
    		"userName":"aUser",
    		"password":"abc123!"
    	}
    },false);
    log("got token "+token);
    
    // step 2: get the current user's ID
    let currentUser= callApi("access/getMe",
    	{"auth": token}
    );
    
    // step3: get the user's ID from the response
    let userId = currentUser.data[0];
    
    
    
    
    // ##### optional generic login method for debugging ##############
    function log(msg){
    	document.write(msg);
    	console.log(msg);
    }
    
    // ##### generic REST API calling method ##############
    function callApi(path,data,parseResult=true){
    	var xhttp = new XMLHttpRequest();
    	xhttp.open("POST", pyramidURL+path, false);
    	xhttp.send(JSON.stringify(data));
    	if(parseResult){
    		return JSON.parse(xhttp.responseText);
    	}else{
    		return xhttp.responseText;
    	}
    }